//
//  NoticeHistoryCell.m
//  智慧小区
//
//  Created by lab603 on 15/7/7.
//  Copyright (c) 2015年 Dreamsoul. All rights reserved.
//

#import "NoticeHistoryCell.h"
#import "NoticeFrame.h"
#import "Notice.h"
@interface NoticeHistoryCell()
//紧急性图标
@property (nonatomic,weak)UIImageView *urgencyView;
//通知标题
@property (nonatomic,weak)UILabel *titleLabel;
//时间Label
@property (nonatomic,weak)UILabel *timeLabel;
//是否已阅读
@property (nonatomic,weak)UIImageView *isReadView;
@end
@implementation NoticeHistoryCell
+ (instancetype)cellWithTableView:tableView{
    static NSString *ID = @"notcieCell";
    NoticeHistoryCell * cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell==nil) {
        cell = [[NoticeHistoryCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
        cell.accessoryType = UITableViewCellAccessoryNone;
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        //通知紧急性
        UIImageView *urgencyView = [[UIImageView alloc] init];
        [self.contentView addSubview:urgencyView];
        _urgencyView = urgencyView;
        //标题label
        UILabel *titleLabel = [[UILabel alloc] init];
        titleLabel.textColor = [UIColor blackColor];
        titleLabel.backgroundColor = [UIColor clearColor];
        titleLabel.font = [UIFont systemFontOfSize:15.0];
        [self.contentView addSubview:titleLabel];
        _titleLabel = titleLabel;
        //时间Label
        UILabel *timeLabel = [[UILabel alloc] init];
        timeLabel.textColor = [UIColor grayColor];
        timeLabel.backgroundColor = [UIColor clearColor];
        timeLabel.font = [UIFont systemFontOfSize:13.0];
        [self.contentView addSubview:timeLabel];
        _timeLabel = timeLabel;
        //是否已阅读的图标
        UIImageView *isReadView = [[UIImageView alloc] init];
        [self.contentView addSubview:isReadView];
        _isReadView = isReadView;
    }
    return self;
}
- (void)setNoticeFrame:(NoticeFrame *)noticeFrame{
    _noticeFrame = noticeFrame;
    Notice *notice = noticeFrame.notice;
    //为控件设置Frame和赋值
    self.urgencyView.frame = noticeFrame.urgencyViewF;
    self.titleLabel.frame = noticeFrame.titleLabelF;
    self.timeLabel.frame = noticeFrame.timeLabelF;
    self.isReadView.frame = noticeFrame.isReadViewF;
    if ([notice.type integerValue]==2) {
        self.urgencyView.image = [UIImage imageNamed:@"propertynotice_important"];
    }else{
        self.urgencyView.image = [UIImage imageNamed:@"propertynotice_unimportant"];
    }
    if ([notice.readId isEqualToString:@"0"]) {
        self.isReadView.image = [UIImage imageNamed:@"propertynotice_not_read"];
    }else{
        self.isReadView.image = [UIImage imageNamed:@"propertynotice_have_read"];
    }
    self.titleLabel.text = notice.title;
    self.timeLabel.text = notice.time;
}
@end
